home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-21 | 1.5 KB | 81 lines | [TEXT/CWIE] |
- #include <LPane.h>
- #include <LCommander.h>
- #include "CSingleCharPane.h"
-
- CSingleCharPane *
- CSingleCharPane::CreateSingleCharPaneStream( LStream *inStream )
- {
- return( new CSingleCharPane( inStream ) );
- }
-
-
- CSingleCharPane::CSingleCharPane( LStream *inStream ) : LPane( inStream )
- {
- mChar = 'x';
- }
-
-
- Boolean
- CSingleCharPane::HandleKeyPress( const EventRecord &inKeyEvent )
- {
- mChar = inKeyEvent.message & charCodeMask;
-
- SetUpdateCommandStatus( true );
- Refresh();
-
- return true;
- }
-
-
- Boolean
- CSingleCharPane::ObeyCommand( CommandT inCommand,
- void *ioParam )
- {
- if ( inCommand == 1000 )
- {
- SysBeep( 20 );
- return true;
- }
- else
- return LCommander::ObeyCommand(inCommand, ioParam);
- }
-
-
- void
- CSingleCharPane::FindCommandStatus( CommandT inCommand,
- Boolean &outEnabled,
- Boolean &outUsesMark,
- Char16 &outMark,
- Str255 outName )
- {
- if (inCommand == 1000)
- outEnabled = (mChar == 'x');
- else
- LCommander::FindCommandStatus(inCommand, outEnabled,
- outUsesMark, outMark, outName);
- }
-
-
- void
- CSingleCharPane::DrawSelf()
- {
- Rect frameRect;
- short x, y, frameWidth, frameHeight;
- const short kFontSize = 128;
- FontInfo myFontInfo;
-
- CalcLocalFrameRect( frameRect );
-
- frameWidth = frameRect.right - frameRect.left;
- frameHeight = frameRect.bottom - frameRect.top;
-
- TextSize( kFontSize );
-
- x = (frameWidth - CharWidth( mChar )) / 2 + frameRect.left;
-
- GetFontInfo( &myFontInfo );
- y = frameRect.bottom - ((frameHeight - myFontInfo.ascent + myFontInfo.descent) / 2);
-
- MoveTo( x, y );
- DrawChar( mChar );
- }